# Copyright (c) 1991-2016 Kawahara Lab., Kyoto University
# Copyright (c) 2001-2005 Shikano Lab., Nara Institute of Science and Technology
# Copyright (c) 2005-2016 Julius project team, Nagoya Institute of Technology
# All rights reserved 
#
SHELL=/bin/sh
.SUFFIXES:
.SUFFIXES: .c .o
.c.o:
	$(CC) $(CFLAGS) $(CPPFLAGS) -o $@ -c $<
guiobj/%.o: %.c
	$(CC) $(CFLAGS) $(CPPFLAGS) $(SDL_CFLAGS) -o $@ -c $<

LIBSENT=../libsent
LIBJULIUS=../libjulius
CC=@CC@
CFLAGS=@CFLAGS@
CPPFLAGS=-I. -I$(LIBJULIUS)/include -I$(LIBSENT)/include @CPPFLAGS@ `$(LIBSENT)/libsent-config --cflags` `$(LIBJULIUS)/libjulius-config --cflags`
LDFLAGS=@LDFLAGS@ -L$(LIBJULIUS) `$(LIBJULIUS)/libjulius-config --libs` -L$(LIBSENT) `$(LIBSENT)/libsent-config --libs`
RM=@RM@ -f
prefix=@prefix@
exec_prefix=@exec_prefix@
INSTALL=@INSTALL@

SDL_CFLAGS=@SDL_CFLAGS@ -DUSE_SDL
SDL_LDFLAGS=@SDL_LIBS@

OBJ=adintool.o options.o mainloop.o
GUIOBJ=guiobj/adintool.o guiobj/options.o guiobj/mainloop.o

EXTRA_TARGET=@extra_target@
ifdef EXTRA_TARGET
GUITARGET=@extra_target@@EXEEXT@
endif

TARGET=adintool@EXEEXT@ $(GUITARGET)

all: $(TARGET)

adintool@EXEEXT@: $(OBJ) $(LIBSENT)/libsent.a $(LIBJULIUS)/libjulius.a
	$(CC) $(CFLAGS) $(CPPFLAGS) -o $@ $(OBJ) $(LDFLAGS)

adintool-gui@EXEEXT@: $(GUIOBJ) $(LIBSENT)/libsent.a $(LIBJULIUS)/libjulius.a
	$(CC) $(CFLAGS) $(CPPFLAGS) $(SDL_CFLAGS) -o $@ $(GUIOBJ) $(LDFLAGS) $(SDL_LDFLAGS)

install: install.bin

install.bin: $(TARGET)
	${INSTALL} -d @bindir@
	@INSTALL_PROGRAM@ $(TARGET) @bindir@

clean:
	$(RM) $(OBJ) $(GUIOBJ)
	$(RM) config.log config.cache
	$(RM) *~ core
	$(RM) adintool adintool@EXEEXT@ adintool-gui adintool-gui@EXEEXT@

distclean:
	$(RM) $(OBJ) $(GUIOBJ)
	$(RM) config.log config.cache
	$(RM) *~ core
	$(RM) adintool adintool@EXEEXT@ adintool-gui adintool-gui@EXEEXT@
	$(RM) config.status
	$(RM) Makefile
